import { createApp } from 'vue'
import './style.css'
import './assets/main.scss'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/es/components/message/style/css'
import 'element-plus/theme-chalk/index.css'
import btnAntiShake from './directive'
import {regAllDirective}from '@/directive/index'

// 时间过滤插件
import moment from 'moment'
const store = createPinia()
const app = createApp(App)

app.use(regAllDirective)
// 防抖
app.use(btnAntiShake)
app.use(router)
app.use(store)
app.mount('#app')
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 时间过滤插件
app.config.globalProperties.$filters = {
  timeFormat(value: string, formatString: string) {
    formatString = formatString || 'YYYY-MM-DD hh:mm:ss';
    return moment(value).format(formatString);
  }
}
